﻿/**************************************************************
 * Copyright www.eastmoney.com. All rights reserved.
 * 
 * Author: gt1987(guitao@eastmoney.com) 
 * Create Date: 2021/2/24 13:10:23
 * Description: 
 *          
 * Revision History:
 *      Date         Author               Description
 *              
***************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace WorkerService.Sample
{
    public interface ITransientService
    {
        void Test();
        Task TestAsync();
    }

    public class TransientService : ITransientService
    {
        private readonly IHttpClientFactory _httpClientFactory;

        public TransientService(IHttpClientFactory httpClientFactory)
        {
            _httpClientFactory = httpClientFactory;
        }

        public void Test()
        {

        }

        public async Task TestAsync()
        {
            var httpClient = _httpClientFactory.CreateClient();
            var response = await httpClient.GetAsync("https://www.baidu.com/");
            Console.WriteLine($"request baidu response code:{response.StatusCode}");
        }
    }
}
